package com.multipledatasource;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

/**
  * @Description: 多数据源切换 + 事物控制
  * @Author: kylin
  * @Date: 2018/10/22 0022 上午 10:55
  */
//将spring boot自带的DataSourceAutoConfiguration禁掉，
// 因为它会读取application.properties文件的spring.datasource.*属性并自动配置单数据源。
// 在@SpringBootApplication注解中添加exclude
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan(basePackages = {"com.multipledatasource.web.mapper"})
public class MultipleDataSourceApplication extends SpringBootServletInitializer {


	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
		return builder.sources(MultipleDataSourceApplication.class);
	}
	//https://www.jb51.net/article/139688.htm
	public static void main(String[] args) {
		SpringApplication.run(MultipleDataSourceApplication.class, args);
	}
}
